$(function(){

    $('#defaultForm').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
        	description:{
            	validators: {
                    notEmpty: {
                        message: '请填写推送内容'
                    }
                }
            },
            pushType:{
            	validators: {
                    notEmpty: {
                        message: '请选择推送类型'
                    }
                }
            }
        }
    }).on('success.form.bv', function(e) {
        // Prevent form submission
        e.preventDefault();

        // Get the form instance
        var $form = $(e.target);

        // Get the BootstrapValidator instance
        var bv = $form.data('bootstrapValidator');

        // Use Ajax to submit form data
        $.post($form.attr('action'), $form.serialize(), function(result) {
        	if(result.errorCode != 200){
        		alert(result.moreInfo);
        		return;
        	}else
        	  alert(commonSuccess);
        	  window.location.href = location.href;
        }, 'json');
    });

	
});